import api from 'api/api.js';
import Router from 'vue-router';
export const getAuth = async (redirect) => {
	// 把当前路由参数给后台 后台跳转begin页的时候会把用户的路由再返回来
	let res = '';
	if(redirect){
		res = await api.getUserAuthUrl({
			requestUri: redirect
		});
	}else{
		res = await api.getUserAuthUrl({});
	}
	
	if (res.code === '0000') {
		console.log(`跳到后台地址 => ${res.result}`);
		location.replace(res.result);
	} else {
		Router.push({
			path: 'error',
			query: {
				message: '请求跳转后台地址失败'
			}
		})
	}
};
